package paf.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class MainFrame extends JFrame {

	private JPanel pnlHeader, pnlContent;
	private JLabel lblHeader;
	private int intCurrentComponent = 0;
	
	protected MainFrame(JPanel panel, UiController uiController) {
		// Create grey header with text
		pnlHeader = new JPanel();
		Color c = new Color(221, 221, 221);
		pnlHeader.setBackground(c);
			lblHeader = new JLabel("Class & Use Case Connector", 2);
			Font f = new Font("Courier", 1, 20);
			lblHeader.setFont(f);
			pnlHeader.add(lblHeader);
		add(pnlHeader, BorderLayout.NORTH);
		
		// Create content panel
		pnlContent = new JPanel(new FlowLayout(FlowLayout.LEFT));
		pnlContent.add(panel);
		add(pnlContent, BorderLayout.LINE_START);
		
		// Set menubar (see MenuBarUI for more info)
		setJMenuBar(new MenuBarUI(uiController));
		setSize(500, 500);
		// Make window maximize jframe by default
		setExtendedState(this.getExtendedState()|Frame.MAXIMIZED_BOTH);
        setResizable(true);
        setTitle("Class and Use Case Connector");
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
	}
	
	public void setPage(JPanel panel) {
		System.out.println("Set panel!");
		pnlContent.getComponent(intCurrentComponent).setVisible(false);
		intCurrentComponent++;
		pnlContent.add(panel);
	}
}
